package com.cz.pg;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;

import java.sql.SQLException;
import java.util.List;

public class ModifyAutoIncrement {
    public static void main(String[] args) {
        try {
            String sql ="SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'mesdb' AND EXTRA = 'auto_increment'";
            List<Entity> listEntity = Db.use().query(sql);
            listEntity.forEach(entity -> {
                 String tableName = entity.getStr("TABLE_NAME");
                 String columnName = entity.getStr("COLUMN_NAME");
                 String sql2 = "ALTER TABLE " + tableName + " MODIFY " + columnName + " INT(11) NOT NULL AUTO_INCREMENT";
            });
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
